
#include <machine/asm.h>

RCSID("$ : strcat.S,v 1.1 2014/08/10 05:47:35 matt Exp $")

/*
 * Implementation of strcat using strlen/strcpy.
 */
ENTRY(strcat)
	stp	x29, x30, [sp, #-32]!	/* save fp, lr */
	mov	x29, sp			/* init fp */
	stp	x27, x28, [x29, #16]	/* save registers */

	mov	x27, x0			/* save dst */
	mov	x28, x1			/* save append */

	bl	_C_LABEL(strlen)	/* find length of dst */

	add	x0, x0, x27		/* add to dst pointer */
	mov	x1, x28			/* fetch append */
	bl	_C_LABEL(strcpy)	/* append string */

	mov	x0, x27			/* restore dst as return value */
	ldp	x27, x28, [x29, #16]	/* save registers */
	ldp	x29, x30, [sp], #32	/* save fp, lr; pop stack */
	ret
END(strcat)
